// pages/mypage/couponSelect/couponSelect.js
const request = require('@/utils/request.js')
const constants = require('@/utils/khyConstants.js')

Page({

  /**
   * 页面的初始数据
   */
  data: {
    qhbImg: getApp().globalData.nginxIp + "/img/wxzhongbao.png",
    ksymyRedData: [],
  },

  getPageData(options) {
    let user = getApp().getUserInfo()
    let userNo = user.userNo
    if (options.userNo) {
      userNo = options.userNo
    }
    request.get('/UserController/getUserCoupon', {userNo: userNo, couponStatus: constants.couponStatus_use}).then(res => {
      console.log(res)
      if (res.data.code == constants.resultSuccessCode
        && res.data.result) {
          let allData = res.data.result || []
          this.setData({
            ksymyRedData: allData,
          })
      }
    })
  },

  receive(e) {
    let shopred = e.currentTarget.dataset.shopred
    if (shopred) {
      getApp().globalData.pageData[constants.page_couponSelect] = shopred
    }
    wx.navigateBack({})
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    getApp().globalData.pageData[constants.page_couponSelect] = {}
    this.getPageData(options)
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})